package com.hig.ledger.service.impl;

import java.util.List;

import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.framework.web.service.TokenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.hig.ledger.mapper.LedgerJobCertificationMapper;
import com.hig.ledger.domain.LedgerJobCertification;
import com.hig.ledger.service.ILedgerJobCertificationService;

/**
 * 职业技能鉴定证书统计Service业务层处理
 *
 * @author scp
 * @date 2024-09-22
 */
@Service
public class LedgerJobCertificationServiceImpl implements ILedgerJobCertificationService
{
    @Autowired
    private LedgerJobCertificationMapper ledgerJobCertificationMapper;
    @Autowired
    private TokenService tokenService;

    /**
     * 查询职业技能鉴定证书统计
     *
     * @param id 职业技能鉴定证书统计ID
     * @return 职业技能鉴定证书统计
     */
    @Override
    public LedgerJobCertification selectLedgerJobCertificationById(Long id)
    {
        return ledgerJobCertificationMapper.selectLedgerJobCertificationById(id);
    }

    /**
     * 查询职业技能鉴定证书统计列表
     *
     * @param ledgerJobCertification 职业技能鉴定证书统计
     * @return 职业技能鉴定证书统计
     */
    @Override
    @DataScope(deptAlias = "d")
    public List<LedgerJobCertification> selectLedgerJobCertificationList(LedgerJobCertification ledgerJobCertification)
    {
        return ledgerJobCertificationMapper.selectLedgerJobCertificationList(ledgerJobCertification);
    }

    /**
     * 新增职业技能鉴定证书统计
     *
     * @param ledgerJobCertification 职业技能鉴定证书统计
     * @return 结果
     */
    @Override
    public int insertLedgerJobCertification(LedgerJobCertification ledgerJobCertification)
    {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        ledgerJobCertification.setCreateBy(loginUser.getUser().getUserName());
        ledgerJobCertification.setDeptId(loginUser.getUser().getDeptId());
//        long id = ledgerJobCertificationMapper.getNextId();
//        ledgerJobCertification.setId(id);
        ledgerJobCertification.setCreateTime(DateUtils.getNowDate());
        return ledgerJobCertificationMapper.insertLedgerJobCertification(ledgerJobCertification);
    }

    /**
     * 修改职业技能鉴定证书统计
     *
     * @param ledgerJobCertification 职业技能鉴定证书统计
     * @return 结果
     */
    @Override
    public int updateLedgerJobCertification(LedgerJobCertification ledgerJobCertification)
    {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        ledgerJobCertification.setUpdateBy(loginUser.getUser().getUserName());
        ledgerJobCertification.setUpdateTime(DateUtils.getNowDate());
        return ledgerJobCertificationMapper.updateLedgerJobCertification(ledgerJobCertification);
    }

    /**
     * 批量删除职业技能鉴定证书统计
     *
     * @param ids 需要删除的职业技能鉴定证书统计ID
     * @return 结果
     */
    @Override
    public int deleteLedgerJobCertificationByIds(Long[] ids)
    {
        return ledgerJobCertificationMapper.deleteLedgerJobCertificationByIds(ids);
    }

    /**
     * 删除职业技能鉴定证书统计信息
     *
     * @param id 职业技能鉴定证书统计ID
     * @return 结果
     */
    @Override
    public int deleteLedgerJobCertificationById(Long id)
    {
        return ledgerJobCertificationMapper.deleteLedgerJobCertificationById(id);
    }
}
